package com.neusoft.resturant.controller;


import com.neusoft.resturant.common.utils.R;
import com.neusoft.resturant.entity.ResShop;
import com.neusoft.resturant.service.IResShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

import static com.neusoft.resturant.common.utils.R.success;

/**
 * 店铺Controller
 * 
 * @author Daniel
 * @date 2023-10-13
 */
@RestController
@RequestMapping("/api/shop")
public class ResShopController
{
    @Autowired
    private IResShopService resShopService;

    /**
     * 查询店铺列表
     */

    @GetMapping("/list")
    public R list(ResShop resShop)
    {
        List<ResShop> list = resShopService.selectResShopList(resShop);
        return R.success(list);

    }

    /**
     * 导出店铺列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResShop resShop)
    {
        List<ResShop> list = resShopService.selectResShopList(resShop);

    }

    /**
     * 获取店铺详细信息
     */
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id)
    {

        return R.success(resShopService.selectResShopById(id));
    }

    /**
     * 新增店铺
     */
    @PostMapping
    public R add(@RequestBody ResShop resShop)
    {

        return R.toAjax(resShopService.insertResShop(resShop));
    }

    /**
     * 修改店铺
     */
    @PutMapping
    public R edit(@RequestBody ResShop resShop)
    {

        return R.toAjax(resShopService.updateResShop(resShop));
    }

    /**
     * 删除店铺
     */
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.toAjax(resShopService.deleteResShopByIds(ids));
    }
}
